<!DOCTYPE html>
<html lang="zh-cn">
   <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>{$CONF['mallTitle']}后台管理中心</title>
      <link href="__PUBLIC__/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <link href="__CSS__/AdminLTE.css" rel="stylesheet" type="text/css" />
      <!--[if lt IE 9]>
      <script src="__PUBLIC__/js/html5shiv.min.js"></script>
      <script src="__PUBLIC__/js/respond.min.js"></script>
      <![endif]-->
      <script src="__PUBLIC__/js/jquery.min.js"></script>
      <script src="__PUBLIC__/plugins/bootstrap/js/bootstrap.min.js"></script>
      <script src="__PUBLIC__/js/common.js"></script>
      <script src="__PUBLIC__/plugins/plugins/plugins.js"></script>
      <link rel="stylesheet" href="__CSS__/layer.css">
      <script type="text/javascript" src="__JS__/layer.js"></script>
      <script type="text/javascript" src="__JS__/layer.ext.js"></script>
   </head>
   <script>
     $(function(){
     layer.config({
                extend: 'extend/layer.ext.js'
      });
  })
   </script>
   <script>
   function del(id){
     Plugins.confirm({title:'信息提示',content:'您确定要删除该中奖纪录吗?',okText:'确定',cancelText:'取消',okFun:function(){
       Plugins.closeWindow();
       Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
       $.post("{:U('Admin/Ggk/delcheat')}",{id:id},function(data,textStatus){
          var json = WST.toJson(data);
          if(json.status=='1'){
            Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
              location.reload();
            }});
          }else{
            Plugins.closeWindow();
            parent.showMsg({msg:'操作失败!',status:'danger'});
          }
        });
        }});
   }


   function checksn(){
     var sn=$('input[name="sn"]').val();
      $.post("{:U('Home/Ggk/checksn')}",{sn:sn},function(data,textStatus){
        var json = WST.toJson(data);
          switch(json.status){
            case 1:
            layer.confirm('<b style="color:red;">'+sn+'</b>中奖码可以使用。<br>奖品：<b style="color:red;">'+json.title+'</b>尚未兑奖。',{btn:['确定']});
            break;
            case 2:
            layer.msg("查询不到该中奖码",{time:2500});
            break;
            case 3:
            layer.msg('你没有查询任何东西');
            break;
            case 4:
            layer.msg('该中奖码已兑奖');
            break;
          }
        });
   }

   </script>
   <body class='wst-page'>
     <form method='get' action="">
       <div class='wst-tbar'> 
    <input type='hidden' id='admin_check' name='admin_check' value='1'/> 
    <a class="btn btn-primary glyphicon glyphicon-search" href="/Admin/Ggk/manage.html?id={$num['id']}">全部</a>
    <a class="btn btn-primary glyphicon glyphicon-search" href="/Admin/Ggk/manage.html?id={$num['id']}&sendstutas=2">已发送奖品</a>
    <a class="btn btn-primary glyphicon glyphicon-search" href="/Admin/Ggk/manage.html?id={$num['id']}&sendstutas=1">未发送奖品</a>

     <a href="/Admin/Ggk/indexlist.html" class="btn btn-primary glyphicon" style="float: right;" >返回</a>

      <a class="btn btn-primary glyphicon glyphicon-search" style="float: right; margin-right: 10px;" href ="{:U('Home/Ggk/exportexcel',array('id'=>$num['id']))}">导出中奖数据</a> 
    
    <div style="margin-top: 10px;">
      <input type="text" name="sn" > <button type="button" class="btn btn-primary glyphicon glyphicon-search" onclick="javascript:checksn()">查询中奖码</button> <span>本次活动奖品总数为：<b style="color:red;">{$num['jpallnums']}</b></span> <span>中奖人数：<b style="color:red;">{$num['zjnums']}</b></span> <span>已发奖品：<b style="color:red;">{$num['sendnums']}</b></span>
    </div>
       </div>
       </form>
       <div class='wst-body'>
        <table class="table table-hover table-striped table-bordered wst-list">
         <thead>
             <tr>
              <th width="50">序号</th>
               <th width='200'>SN码（中奖码）</th>
               <th width="100">奖项</th>
               <th width="100">是否已发奖品</th>
               <th width="120">奖品发送时间</th>
               <th width="100">用户名称</th>
               <th width="200">收货信息</th>
               <th width='50' style="text-align: center;">操作</th>
             </tr>
           </thead>
           <tbody>
          <volist name='list' id='vo'>
           <tr>
           <td>{$vo['id']}
           </td>
             <td>
              {$vo['sn']}
             </td>
           <td>
         {$vo['jp']}
           </td>
           <td>
             <?php 
             switch($vo['sendstutas']){
              case '0':
              echo "<b>准备中</b>";
              break;
              case '1':
              echo "<b style='display: block;height: 20px;'>配送中</b>";
              $id=$vo["id"];
              echo "<span style='cursor:pointer; ' onclick='javascript:checkml($id)'>查看物流</span>";
              break;
              case '2':
              echo "<b style='display: block;height: 20px;'>已签收</b>";
              $id=$vo["id"];
              echo "<span style='cursor:pointer; ' onclick='javascript:checkml($id)'>查看物流</span>";
              break;
              case '3':
              echo "<b>已其他方式发奖</b>";
              break;

             }
             ?>
           </td>
           <td>
             <?php if((int)$vo['sendtime']==0){
             echo "待定";
             }else{ ?>
             {$vo['sendtime']|date='Y-m-d H:i',###}

             <?php } ?>
           </td>
          <td>{$vo['userName']}</td>
          <td>
            <?php if($vo['addressId']!=0){ ?>
            {$vo['ress'][str]}
            <?php }else{ 
            echo "<b>未选择地址</b>";
            } ?>

          </td>
           <td style="width: 150px;text-align: center;font-size: 15px;"> 
           <a href="/Admin/Ggk/update.html?id={$vo['id']}">[编辑]</a> |
           <a style="cursor: pointer;" onclick="javascript:del({$vo['id']})">[删除]</a>
           </td>
           </tr>
           </volist>
           <tr>
             <td colspan='8' class="nav_down" >{$show}</td>
           </tr>
           </tbody>
        </table>
       </div>
    <script type="text/javascript">
  function checkml(id){
        $.ajax({
          url:"/Home/Ggk/getwuliumsg.html",
          data:{
            id:id
          },
          beforesend:function(){
            alert(11111);
          },
          success:function(data){
            if(data.status!=2){
            var top = "<div style='padding: 10px; text-align: center;'>快递公司：<b style='color:blue;padding-right: 10px;'>"+data.gs+"</b> 快递单号：<b style='color:red;padding-right: 10px;'>"+data.nu+"</b><b style='color:blue;padding-right: 10px;'>"+data.state+"</b></div>";
              var title="<table class='table table-hover table-striped table-bordered wst-list'><thead><tr><th>时间</th><th>地点和跟踪进度</th></tr></thead><tbody>";
              var footer = "</tbody></table>";
              var con ='';
               if (data.msg) {
                  var json = eval(data.msg);
                  $.each(json,function(key,value){
                    con+="<tr><td>"+value.time+"</td><td>"+value.context+"</td></tr>";
                  })
                 }
              layer.open({
              title :'查看物流',
              type: 1,
              skin: 'layui-layer-rim', //加上边框
              area: ['600px', '640px'], //宽高
              content: top+title+con+footer,
            });
            }else{  
              layer.msg('该快递单号出错',{icon:2});
              return;}
              

          }
        })
      }
    </script>
   </body>
</html>